package com.es.action.heat.exec.exectime;

/**
 * 文件保存后执行，单例
 *
 * @author Will
 */
public class SaveStart extends BaseStrategy {

    private static volatile SaveStart instance = null;
    /**
     * 判断初始执行标识
     */
    private boolean flag = false;

    private SaveStart() {
    }

    /**
     * 单例实现
     *
     * @return instance
     */
    public static SaveStart getInstance() {
        if (instance == null) {
            synchronized (SaveStart.class) {
                if (instance == null) {
                    instance = new SaveStart();
                }
            }
        }
        return instance;
    }

    @Override
    public void run() {
        runEx();
    }

    private void runEx() {
        if (flag) {
            start();
        } else {
            flag = true;
        }
    }
}